//If you want to restrict players from modifying or allow players to modify other players' stuff, do so here.

local kludge
local event = function(pl,ent)
	//Return true for allow access, false for disallow
	//Installer script hooks are included so automatic installers can search for the string "//INSTALLER_SCRIPT_HOOK_2" and replace it with code
	//I suggest injecting code at //INSTALLER_SCRIPT_HOOK_2 and setting override = true at //INSTALLER_SCRIPT_HOOK_1
	//A backup copy of this script is included so repairs can be made automatically
	
	local override = false
	//INSTALLER_SCRIPT_HOOK_PL_1
	
	if not override then
		if type(SPropProtection) == "table" and type(SPropProtection.PlayerCanTouch) == "function" then
			//Simple Prop Protection 1.5
			return SPropProtection.PlayerCanTouch(pl,ent)
		end
	end
	
	if pl:IsAdmin() or pl:IsSuperAdmin() then
		return true
	end
	
	//INSTALLER_SCRIPT_HOOK_PL_2
	
	//This kludge will attempt to restrict players from uploading and downloading code to entities spawned by other players.
	return kludge(pl,ent)
end

//Do not make code changes below this line.












































function luachip.playerAccess(pl,ent)
	//Do not modify this function
	if ent and IsEntity(ent) and ent:IsPlayer() then
		return false
	end
	
	if IsEntity(pl) and pl:IsPlayer() then
		local b = event(pl,ent)
		if IsValid(ent) and ent:GetTable() then
			local tab = ent:GetTable()
			if not tab.luachipAccess then
				tab.luachipAccess = {}
			end
			tab.luachipAccess[pl:UniqueID()] = b
		end
		
		return b
	elseif type(pl) == "string" then
		//This allows a player's contraption to keep working after they leave the server
		if IsValid(ent) and ent:GetTable() then
			local tab = ent:GetTable()
			if not tab.luachipAccess then
				tab.luachipAccess = {}
			end
			v:ChatPrint("STRALLOW: "..tostring(tab.luachipAccess[pl]))
			return tab.luachipAccess[pl]
		end
	end
end

kludge = function(pl,ent)
	//Do not modify this function
	//KLUDGE: Look in OnDieFunctions to determine owner to stay low profile
	if IsEntity(ent) then
		local tab = ent:GetTable()
		if
			type(tab.OnDieFunctions) == "table" and
			type(tab.OnDieFunctions.GetCountUpdate) == "table" and
			type(tab.OnDieFunctions.GetCountUpdate.Args) == "table" and
			type(tab.OnDieFunctions.GetCountUpdate.Args[1]) == "Player"
		then
			if pl ~= tab.OnDieFunctions.GetCountUpdate.Args[1] then
				return false
			end
		end
	end
	
	return true
	//How is that for hacky?
end